package DemoText;
import java.util.Scanner;

/**
 * 特殊年份
 */
public class LuoGuP8752 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int ret = 0;
        for (int i = 0; i < 5; i++) {
            int n = in.nextInt();
            if (isSame(n) && isBigOne(n)) ret++;
        }
        System.out.println(ret);
    }

    private static boolean isBigOne(int n) {
        return n % 10 - 1 == n / 100 % 10;
    }

    private static boolean isSame (int n) {
        return n / 1000 == n / 10 % 10;
    }
}